#include "bigboss.h"
#include<vector>

using namespace std;

BigBoss::BigBoss(const vector<vector<int>>& map, QWidget *parent)
    : QWidget{parent}, pathfinder(map), currentPathIndex(0)
{

}
void BigBoss::setPosition(int x, int y)
{
    this->x = x;
    this->y = y;
}

void BigBoss::findPlayer(int playerX, int playerY)
{
    if (currentPathIndex >= static_cast<int>(path.size()) || path.empty()) {
        path = pathfinder.findPath(QPoint(x, y), QPoint(playerX, playerY));
        currentPathIndex = 0;
    }

    if (currentPathIndex < static_cast<int>(path.size())) {
        auto nextPoint = path[currentPathIndex];
        x = nextPoint.x();
        y = nextPoint.y();
        currentPathIndex++;
    }
}


int BigBoss::getX() const
{
    return x;
}

int BigBoss::getY() const
{
    return y;
}
